<%--
 *  File:    ActivityManageCostDetail.jsp
 *  @Author: only jin
 *  Date:    2009/10/22
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.log4j.Category"%>

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval"%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>
<%
	  //init param
  String privilegeCode = "SFE0150";
  String strTableName = "";
  String strModuleName = "CRM";
  	String contextPath = request.getContextPath();
%>


<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<%@ include file="/rpt/ReportURL.inc"%>

<html>
<iframe name="reloadHandler" style="display:none" ></iframe>
<head>
<title>ActivityManageCostDetail</title>

<PageFlow:CheckPageFlow pageName="p_activitymanagecostdetail" />
<% 
          Vector totalsummary = (Vector) pageContext.getAttribute("totalsummary");
          if (totalsummary == null)
              totalsummary = new Vector();
          Integer activitymanageid =  (Integer)pageContext.getAttribute("activitymanageid");
          
          
          Integer count =  (Integer)pageContext.getAttribute("count");
%>          
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/summary.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>

<%@ include file="/inc/SummaryDivision.inc" %>
<script language="JavaScript">

function page_return(){
	//self.location.href='DistributortenderSummary.jsp?<%= OvalTools.randomURL() %>';
	parent.location.href = "ActivityManageSummary.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode%>";
}
	
function page_done()
{
  if(!checkForm(frm)) return; 	
	emptyToNull(frm);
	
  document.frm.actionname.value="save";
  document.frm.target="_parent";
  isRunning = true;
  document.frm.submit();
}	




function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(frm,actionvalue,orderbyname);
  if(!editform) return;
  editform.action = "ActivityManageCostDetail.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}

function page_delete(){
	if(nullChecked(document.frm.deleteids,"<%=JspHelper.filterNull(totalsummary.size())%>"))
	  {
	    alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD") %>");
	    return;
	  }
	if ( ! confirm("<%= message.getMessageDesc("ARE_YOU_SURE")%>") ) 
	    return;
	    frm.actionname.value = "delete";
		frm.target = "_self";
		isRunning = true;
		frm.submit();
}

function page_add(){
	
	  if(!checkForm(frm)) return; 	
		emptyToNull(frm);
			
	var applyprice=document.frm.applyprice.value;
	if(applyprice!=null && !isNumeric(applyprice))
	{
		alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER_TYPE",label.getLabelName("L_AppliCation")+label.getLabelName("L_Price1"))%>");
		document.frm.applyprice.select();
		return;
	}

	var agreeprice=document.frm.agreeprice.value;
	if(agreeprice!=null && !isNumeric(agreeprice))
	{
		alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER_TYPE",label.getLabelName("L_Agreement")+label.getLabelName("L_Price1"))%>");
		document.frm.agreeprice.select();
		return;
	}
	 
	frm.actionname.value = "add";
	frm.target = "_self";
	isRunning = true;
	frm.submit();
}


function page_save(){
	
	  //if(!checkForm(frm)) return; 	
		//emptyToNull(frm);
			
	var applyprice=document.frm.applyprice.value;
	if(applyprice!=null && !isNumeric(applyprice))
	{
		alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER_TYPE",label.getLabelName("L_AppliCation")+label.getLabelName("L_Price1"))%>");
		document.frm.applyprice.select();
		return;
	}

	var agreeprice=document.frm.agreeprice.value;
	if(agreeprice!=null && !isNumeric(agreeprice))
	{
		alert("<%= message.getMessageDesc("VALUE_MUST_BE_NUMBER_TYPE",label.getLabelName("L_Agreement")+label.getLabelName("L_Price1"))%>");
		document.frm.agreeprice.select();
		return;
	}
	 
	frm.actionname.value = "save";
	frm.target = "_self";
	isRunning = true;
	frm.submit();
}

var popwindow;
function page_selectProd(){
   
	var url = "<%=contextPath%>/sfe/ProductSelect.jsp?<%= OvalTools.randomURL()%>";
	var windowAttribute = "height=250, width=400,top=100,left=100, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=yes";
  	if(popwindow!=null) popwindow.close();
  	popwindow = window.open(url,null,windowAttribute);
}

function page_setproduct(id,umcode,prodcode,prodname){
	frm.prodids.value = id;
	frm.prodcode.value = prodcode;
	frm.prodname.value = prodname;
}

function page_price(){
	var myform = eval("document.frm");
	var ratenumber="";
	var ratenumber1="";
	for(i=0;i<Number(myform.numrows.value);i++)
	{
		var objnumber=eval("myform.applyprice"+i).value;
		ratenumber =(Number(objnumber)+Number(ratenumber));
		var objnumber1=eval("myform.agreeprice"+i).value;
		ratenumber1 =(Number(objnumber1)+Number(ratenumber1));
	}
	//本页合计
	myform.applytotalamount1.value=ratenumber;
	myform.agreetotalamount1.value=ratenumber1;
	//总合计
	//myform.applytotalamount.value=myform.applytotalamount1.value;
	//myform.agreetotalamount.value=ratenumber1;

	//人均费用
	
	var totalamount=myform.applytotalamount.value;
	var count=myform.count.value;
     myform.augempamount.value=(totalamount/count).toFixed(2);

}

</script>
</head>
<body onload="page_price();">

<table width="100%" cellspacing="0" cellpadding="0">
	<form id="frm"  name="frm" method="post" action="../../Dispatcher">
	<input type="hidden" name="pagename" value="p_activitymanagecostdetail">
	<input type="hidden" name="actionname">
	<input type="hidden" name="numrows" value="<%=totalsummary.size() %>">
	<custom:hidden property="orgid" name="userinfo" scope="session"/>
	<custom:hidden property="userid" changedName="maker" name="userinfo" scope="session"/>
	<input type="hidden" name="activitymanageid" value="<%=activitymanageid %>">
	<input type="hidden" name="count" value="<%=count %>">
	
		<%
		    Vector alltype=(Vector)pageContext.getAttribute("alltype");
		    if(alltype==null)
		    {
		        alltype=new Vector();
		    }
		    System.out.print("-----------------"+alltype);
		    HashMap newhashinfo=(HashMap)pageContext.getAttribute("newhashinfo");
		    if(newhashinfo==null)
		    {
		    	newhashinfo=new HashMap();
		    }
		    
		    HashMap visitprocessinfo=(HashMap)pageContext.getAttribute("visitprocessinfo");
		    if(visitprocessinfo==null)
		    {
		    	visitprocessinfo=new HashMap();
		    }
		%>
	
		<table width="100%" cellspacing="0" border="0" cellpadding="0">

	 
	    <tr> 
		    <td> 
		      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" >
		        <tr class="deepblue-left">
		          <td width="5%" class="title_center">&nbsp;</td>
		          <td class="title_center" width="8%"><font color="red"><%=label.getLabelName("L_Expense")+label.getLabelName("L_ProdCategoryCode")%></font></td>
		          
		          <!-- <td class="title_center" width="8%"><%=label.getLabelName("L_Expense")+label.getLabelName("L_Type")%></td> -->
		          
                  <td class="title_center" width="15%"><%= label.getLabelName("L_ProdCode") %></td>
                  <td class="title_center" width="15%"><%= label.getLabelName("L_ProdName") %></td>
		          <td class="title_center" width="10%"><%=label.getLabelName("L_AppliCation")+label.getLabelName("L_Price1")  %></td>
		          
		          <!-- 批复金额 -->
		          <%--if(visitprocessinfo.get("status")!=null && ((Integer)visitprocessinfo.get("status")).intValue() == 10){%>	
                  <td style="display:none" >&nbsp;</td>
                  <% }else { --%>
                  
                  <td class="title_center" width="10%" ><%=label.getLabelName("L_Agreement")+label.getLabelName("L_Price1")  %></td>
                  <%--} --%>
                  
                  <!-- 实际执行金额 -->
                  
                  <td class="title_center" width="10%" ><%=label.getLabelName("L_ImplementationAmount ")  %></td>
                  
                  <td class="title_center" width="20%"><%=label.getLabelName("L_comment") %></td>
                  <!-- 
                  <td class="title_center" width="8%"><%=label.getLabelName("L_AppliCation")+label.getLabelName("L_Price1")+label.getLabelName("L_TotalAmount") %></td>
                  <td class="title_center" width="8%"><%=label.getLabelName("L_Agreement")+label.getLabelName("L_Price1")+label.getLabelName("L_TotalAmount") %></td>		          
                   -->
		        </tr>
	
		        <%
	            	int i = 0;
	             	String strClassType = new String();
	          	%>
		         <logic:iterate id="onerow" collection="<%=totalsummary %>" indexId="idx"> 
		           	<%
		            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
		            	if(i%2 == 1)
		            	{
		              		strClassType = "td-listrom";
		            	}else{
		              		strClassType = "";
		            	}
		            	i++;
		            	
		          	%>
					<tr class="<%=JspHelper.filterNull( strClassType )%>">
						<td class="td_center">
							<input type="checkbox" name="deleteids" value="<%=JspHelper.filterNull(tempMap.get("activitymanagecostid") )%>" class="checkbox">
						</td>
						<custom:hidden name="onerow" property="activitymanagecostid" colIndex="<%=idx %>"/>        	
						<td>&nbsp;<custom:write name="onerow" property="valuename" nbsp="true" /></td>
						<!-- <td>&nbsp;<custom:write name="onerow" property="activityexpensetypename" nbsp="true" /></td> -->
						<td>&nbsp;<custom:write name="onerow" property="prodcode" nbsp="true" /></td>
						<td>&nbsp;<custom:write name="onerow" property="prodname" nbsp="true" /></td>
						
						<%if(visitprocessinfo.get("status")!=null && ((Integer)visitprocessinfo.get("status")).intValue() != 10){%>
						<td ><custom:text name="onerow" property="applyprice" colIndex="<%=idx %>"/></td>
						<%}else{ %>
						<td><custom:write name="onerow" property="applyprice" nbsp="true" />
						    <custom:hidden name="onerow" property="applyprice" colIndex="<%=idx %>"/>
						</td>
						<%} %>
						<%if(visitprocessinfo.get("status")!=null && ((Integer)visitprocessinfo.get("status")).intValue() != 10){%> 
						<td ><custom:text name="onerow" property="agreeprice" colIndex="<%=idx %>"/></td>
						<%}else{ %>
						<td ><custom:write name="onerow" property="agreeprice" nbsp="true" />
						     <custom:hidden name="onerow" property="agreeprice" colIndex="<%=idx %>"/>
						</td>
						<%} %>	
						<%if(visitprocessinfo.get("status")!=null && ((Integer)visitprocessinfo.get("status")).intValue() != 40){%> 
						<td><custom:write name="onerow" property="implementationamount" nbsp="true" /></td> 
								  <custom:hidden name="onerow" property="implementationamount" colIndex="<%=idx %>"/>
						<%}else{ %>
						<td ><custom:text name="onerow" property="implementationamount" colIndex="<%=idx %>"/></td>
					    <%} %>				
						<td><custom:write name="onerow" property="comments" nbsp="true" /></td> 
						
						<!-- 
						<td>&nbsp;<custom:write name="onerow" property="applytotalamount" nbsp="true" /></td>
						<td>&nbsp;<custom:write name="onerow" property="agreetotalamount" nbsp="true" /></td>												 						
						 -->
		     	 </logic:iterate>
		     	 <tr>
		     	 	 <td>&nbsp;</td>
					 <td><custom:select name="newhash" property="activitysourceid" optionsName="alltype" command="notnull" 
						label="L_Expense" optionValueKey="activitysourceid" optionInnerTextKey="name" defaultValue="--------------" defaultValueCost=""/> 
					 </td>
					 
					 <!-- <td><custom:selectdic name="newhash"  property="activityexpensetype" dictType="ActivityExpenseType"  defaultValue="-----------"  defaultValueCost = " " label="L_Type"/></td> -->
					 
					 <td><custom:text name="newhash" property="prodcode" size="20" readonly="true" />
							<a onclick="page_selectProd();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a>
							<custom:hidden  property="prodids" />
					 </td>
					 <td><custom:text name="newhash" property="prodname" size="30" readonly="true"/></td>
					 <td><custom:text property="applyprice" maxlength="16"  name="newhash" onchange="page_price()"/>&nbsp;</td>
					 
			          <%if(visitprocessinfo.get("status")!=null && ((Integer)visitprocessinfo.get("status")).intValue() == 10){%>					 
					 <td ><custom:text property="agreeprice" maxlength="64" name="newhash" onchange="page_price()" readonly="true"/>&nbsp;</td>
					 <%}else{ %>
					 <td><custom:text property="agreeprice" maxlength="64"  name="newhash" onchange="page_price()"/>&nbsp;</td>
					 <%} %>
					 
					 <%if(visitprocessinfo.get("status")!=null && ((Integer)visitprocessinfo.get("status")).intValue() == 40){%>
					 
					 <td><custom:text property="implementationamount" maxlength="64"  name="newhash" onchange="page_price()"/>&nbsp;</td>
					
					 <%}else{ %>
					 
					 <td ><custom:text property="implementationamount" maxlength="64"  name="newhash" onchange="page_price()" readonly="true"/>&nbsp;</td>
					 <%} %>
					 <td><custom:textarea name="newhash" property="comments" rows="1" cols="30"/></td>
					 <!-- 
					 <td><custom:write name="newhash" property="applytotalamount" nbsp="true"/></td>
					 <td><custom:write name="newhash" property="agreetotalamount" nbsp="true"/></td>
					  -->
				</tr>
		     	 <tr>
		     	 	 <td colspan="4" style="text-align:right"><%=label.getLabelName("L_PageSum") +  label.getLabelName("L_Colon")%></td>
					 <td class="red"><input type="text" name="applytotalamount1" size="10"  style="border:0;color:red"/>
					 </td>
					 <%--if(visitprocessinfo.get("status")!=null && ((Integer)visitprocessinfo.get("status")).intValue() == 10){%>
					 <td  style="display:none" class="red"><input type="text" name="agreetotalamount1" size="10"  style="border:0;color:red"/>
					 <%}else{ --%>
					 <td class="red"><input type="text" name="agreetotalamount1" size="10"  style="border:0;color:red"/>
					 <%--} --%>
					 </td>
					 <td>&nbsp;</td>
					 <td>&nbsp;</td>

				</tr>	
				
				<tr>
		     	 	 <td colspan="4" style="text-align:right"><%=label.getLabelName("L_AugEmpAmount") +  label.getLabelName("L_Colon")%></td>
					 <td class="red"><input type="text" name="augempamount" size="10"  style="border:0;color:red"/>
					 </td>
					 
					 <%--if(visitprocessinfo.get("status")!=null && ((Integer)visitprocessinfo.get("status")).intValue() == 10){%>
					 <td style="display:none" >&nbsp;</td>
					  <%}else{--%>
					  <td>&nbsp;</td>
					  <%--} --%>
					 <td>&nbsp;</td>
					 <td>&nbsp;</td>

				</tr>	
											
		     	 <tr>
					<td colspan="4" style="text-align:right"><%=label.getLabelName("L_TotalSum") +  label.getLabelName("L_Colon")%></td>
					 <td class="red">
					 	 <custom:text name="newhashinfo" property="applytotalamount" size="10" readonly="true" style="border:0;color:red"/>
					 </td>
					 <%--if(visitprocessinfo.get("status")!=null && ((Integer)visitprocessinfo.get("status")).intValue() == 10){%>
					 <td style="display:none" >&nbsp;</td>
					 <%}else{ --%>	
					 <td class="red"><custom:text name="newhashinfo" property="agreetotalamount" size="10" readonly="true" style="border:0;color:red"/></td>
					 <%--} --%>
					 <td>&nbsp;</td>
					 <td>&nbsp;</td>

				</tr>				
		      <%@ include file="/inc/SummaryAction.inc" %>
		      </table>	      
		      </td>
		      </tr>
		      <tr>
		      <td>
		      
		      <table width="100%" cellspacing="0" cellpadding="0">
		        <tr> 
		          <td class="summary_top"></td>
		        </tr>
		        <tr>
				     <td class="td_center">
						<a onclick='page_add()'><custom:button type="2"	label="L_Add" imgsrc="add_btn.gif" border="0" style="width:60" /></a>
						<a onclick="page_delete()"><custom:button type="2" label="L_Delete" imgsrc="delete_btn.gif" border="0" style="width:60" /></a>
						<%if(totalsummary.size()>0){ %>
						<a onclick="page_save()"><custom:button type="2" label="L_Save" imgsrc="delete.gif" border="0" style="width:60"/></a>
						<%} %>
						<a onclick="page_return()"><custom:button type="1" label="L_Back" border="0"  imgsrc="finish.gif" style="width:60" /></a>
					 </td>
				</tr>
		      </table>
		    </td>
	  </tr>
	</table>
</form>
</body>
</html>



